package com.mrobuy.type;

import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;

/**
 * 申请状态
 *
 *  状态:(  302:待采销审核,304:待产品审核,306:审核通过,303:采销驳回,  305:产品驳回,309:待经理审核,310:经理驳回,311:待总监审核,
 *         312:总监驳回,  319:待质量管理部审核,320:质量管理部驳,321:待质量负责人审核,  322:质量负责人驳回)
 */
public enum ApplyState {

    UNKONWN(0, "状态未知"),

    STATE_302(302, "待采销审核"),
    STATE_304(304, "待产品审核"),
    STATE_306(306, "审核通过"),
    STATE_303(303, "采销驳回", true),
    STATE_305(305, "产品驳回", true),
    STATE_309(309, "待经理审核"),
    STATE_310(310, "经理驳回", true),
    STATE_311(311, "待总监审核"),
    STATE_312(312, "总监驳回", true),
    STATE_319(312, "待质量管理部审核"),
    STATE_320(320, "质量管理部驳", true),
    STATE_321(321, "待质量负责人审核"),
    STATE_322(322, "质量负责人驳回", true);

    private final static Map<Integer, ApplyState> map = new ConcurrentHashMap<>();

    static {
        for (ApplyState applyState : ApplyState.values()) {
            map.put(applyState.code, applyState);
        }
    }

    public static ApplyState getStateByCode(Integer code){
        if ( map.containsKey(code) ) {
            return map.get(code);
        }

        return UNKONWN;
    }

    private int code;
    private String desc;
    private boolean reject;

    ApplyState(int code, String desc) {
       this(code, desc, false);
    }

    ApplyState(int code, String desc, boolean reject) {
        this.code = code;
        this.desc = desc;
        this.reject = reject;
    }

    public int code() {
        return code;
    }

    public String desc() {
        return desc;
    }

    public boolean reject() {
        return reject;
    }
}
